public class Solution {
    public int removeDuplicates(int[] nums) {
        int slow = 0, fast = 1;
        while(fast < nums.length){
            while(nums[fast] == nums[slow]){
                fast++;
                if(fast >= nums.length){
                    return ++slow;
                }
            }
            slow++;
            nums[slow] = nums[fast];
        }
        return ++slow;
    }
}
